#ifndef DESKTOPHELPER_H
#define DESKTOPHELPER_H

class DesktopHelper;

#include "Utilities.h"
#include "common.h"

typedef bool (*ENUMDESKICONPROC)(HWND desktopHWnd, RECT desktopBounds, int itemIndex, LPCTSTR itemText, POINT itemPosition, RECT iconBounds, SIZE gridSize, bool first, bool last, LPARAM lParam1, LPARAM lParam2);

struct DLL DesktopItem
{
	int Index;
	tstring Text;
	POINT Location;
	RECT Bounds;
};

struct DLL DesktopInfo
{
	HWND HWnd;
	RECT Bounds;
	SIZE GridSize;
};

class DLL DesktopItemSortTemplate
{
public:
	inline bool operator()(DesktopItem di1, DesktopItem di2) const
	{
		//return di1.Index < di2.Index;
		//alphabetical
		return 	_tcsicmp(di1.Text.c_str(),di2.Text.c_str()) < 0;
	}
};

class DLL DesktopHelper
{
public:
	
	DesktopHelper(bool refreshDesktopItems = false);
	~DesktopHelper();
	bool GetDesktopAlignToGrid();
	bool GetDesktopAutoArrange();
	void SetDesktopAlignToGrid(bool value);
	void SetDesktopAutoArrange(bool value);
	void RefreshDesktop();
	int GetDesktopItemCount();

	DesktopInfo DesktopInfo;
	set<DesktopItem, DesktopItemSortTemplate> DesktopItems;
	void RefreshDesktopItems();

private:
	HANDLE hProcessDesktop;
	int * desktopVMPtr;

};

#endif